# 作者：陈睿-cruise
# 2025年02月19日15时47分27秒
# 2979386061@qq.com
import threading
import time

# 模拟 I/O 密集型任务：多个线程共享同一内存空间。它们之间可以轻松共享数据和资源
def io_task(thread_id):
    print(f"Thread {thread_id} started I/O task")
    time.sleep(3)  # 模拟 I/O 操作，例如文件读取或网络请求
    print(f"Thread {thread_id} finished I/O task")

if __name__ == "__main__":
    print("Main thread started")

    threads = []
    for i in range(5):
        thread = threading.Thread(target=io_task, args=(i,))
        threads.append(thread)
        thread.start()

    # 等待所有线程完成
    for thread in threads:
        thread.join()

    print("Main thread finished")
